
	******************************************************************
	**
	**
	**		NAME:		GUY GROSSMAN, YOTAM MARGALIT, TAMAR MITTS
	**		DATE: 		December 15, 2021
	**		PROJECT: 	Israel Hayom
	**		DETAILS: 	This code generates Table 5 & SI18 & SI19
	**		Version: 	Stata MP 16
	**
	******************************************************************
	
			**	**	**	**	**	**	**	**	**	**	**	**	**
			**	**	**	**	**	**	**	**	**	**	**	**	**
			**	**	**	**	**	**	**	**	**	**	**	**	**

	set more off
	clear all
	version 16
	set linesize 80
	macro drop _all
	set matsize 800
	 
	* set cd 

	capture cd "~/dropbox/Israeli Newspapers Study/JOP_REPLICATION/Dataverse submission"

	* Runnning program for generating indices 
	do "Code/make_index_gr.do"

	* Bring-in data

	use "Data/ines_survey_final.dta"
	sort area_num semel_yeshuv year
	drop if israelhayom_percent_2008==.
	gen id =_n

	* Defining treatment var

	center israelhayom_percent_2008, standardize gen(IHsd)

	gen IH=israelhayom_percent_2008  
	replace IH=0 if year==0
	move IH v6 

	* Defining the control var

	gl covs male age degree class v175
	su $covs

	gl controls $covs age_miss degree_miss class_miss
	su $controls

	* Defining weights

	gen obs=1
	bys semel_yeshuv year: egen obssemel = total(obs)
	bys area_num year: egen obsarea = total(obs)

	*************************************
	* Party respondent feels closest to *
	*************************************
			
	gen KadimaF=v68==1
	replace KadimaF=. if v68==.
	lab var KadimaF "Kadima most favored party"

	gen LaborF=v68==2
	replace LaborF=. if v68==.
	lab var LaborF "Labor most favored party"

	gen LikudF=v68==3
	replace LikudF=. if v68==.
	lab var LikudF "Likud most favored party"

	gen MeretzF=v68==4
	replace MeretzF=. if v68==.
	lab var MeretzF "Meretz most favored party"

	gen HabayitHayehudiF=v68==5
	replace HabayitHayehudiF=. if v68==.
	lab var HabayitHayehudiF "Habayit Hayehudi most favored party"

	gen  IsraelBeiteinuF=v68==6
	replace IsraelBeiteinuF=. if v68==.
	lab var IsraelBeiteinuF "Israel Beiteinu most favored party"

	gen  ShasF=v68==7
	replace ShasF=. if v68==.
	lab var ShasF "Shas most favored party"

	local partyF KadimaF LaborF LikudF MeretzF HabayitHayehudiF IsraelBeiteinuF ShasF 
	su `partyF' 
	tabstat `partyF', by (year) stats(mean N)

	******************************
	* Party rating on 1-10 scale *
	******************************

	ren v61 KadimaS
	ren v62 LaborS
	ren v63 LikudS
	ren v64 MeretzS
	ren v65 HabayitHayehudiS
	ren v66 IsraelBeiteinuS
	ren v67 ShasS

	local partyS KadimaS LaborS LikudS MeretzS HabayitHayehudiS IsraelBeiteinuS ShasS
	su `partyS'
	tabstat `partyS', by (year) stats(mean N)

	*********************************
	* Identifying Netanyahu support *
	*********************************

	lab var v123B " Netanyahu best: Leadership"
	lab var v125B " Netanyahu best: Trustworthiness"
	lab var v127B " Netanyahu best: Patriotic"
	lab var v129B " Netanyahu best: Negotiator"
	lab var v131B " Netanyahu best: Protect rule of law"

	foreach var in v71 v123B v125B v127B v129B v131B {
	
		quietly summarize `var' if year==0
		local `var'_mean= r(mean)
		local `var'_sd= r(sd) 
		gen c_`var' = (`var'-``var'_mean')/``var'_sd'
		
		egen median_std_`var'1=median(c_`var') if year==1
		replace c_`var' = median_std_`var'1 if year==1 & c_`var'==.
		qui egen median_std_`var'0=median(c_`var') if year==0
		replace c_`var' = median_std_`var'0 if year==0 & c_`var'==.
		
		egen median_`var'1=median(`var') if year==1
		replace `var' = median_`var'1 if year==1 & `var'==.
		qui egen median_`var'0=median(`var') if year==0
		replace `var' = median_`var'0 if year==0 & `var'==.
		drop median_`var'0 median_`var'1 median_std_`var'0 median_std_`var'1
		
		}

	* Create indices	
	
	alpha c_v71 c_v123B c_v125B c_v127B c_v129B c_v131B, item std	
	alpha c_v71 c_v123B c_v125B c_v127B c_v129B c_v131B, gen(Netanyahu) std	

	gen wgt	=1
	gen stdgroup=IH==0

	make_index_gr Netanyahu wgt v71 v123B v125B v127B v129B v131B
	lab var Netanyahu "Attitudes toward Netanyahu index"
	lab var index_Netanyahu "Attitudes toward Netanyahu index"
	corr Netanyahu index_Netanyahu

	local Netanyahu Netanyahu index_Netanyahu v71 v123B v125B v127B v129B 
	tabstat `Netanyahu', by (year) stats(mean N)

	****************************
	* Likud and Kadima support *
	****************************
	
	foreach var in v109 v111 v113 v115 v117 v121 {
	gen `var'B= `var'==2
	replace `var'B=. if `var'==.
	gen `var'C= `var'==1
	replace `var'C=. if `var'==.
	}

	lab var v109B "Likud: best party to protect Israel's interests in peace talks"
	lab var v111B "Likud: best party to protect Israel's democratic institutions"
	lab var v113B "Likud: best party to reach a lasting peace agreement"
	lab var v115B "Likud: best party to handle terrorism"
	lab var v117B "Likud: best party to secure Jewish majority"
	lab var v121B "Likud: best party to reduce income inequality"

	lab var v109C "Kadima: best party to protect Israel's interests in peace talks"
	lab var v111C "Kadima: best party to protect Israel's democratic institutions"
	lab var v113C "Kadima: best party to reach a lasting peace agreement"
	lab var v115C "Kadima: best party to handle terrorism"
	lab var v117C "Kadima: best party to secure Jewish majority"
	lab var v121C "Kadima: best party to reduce income inequality"

	su v109B v111B v113B v115B v117B v121B
	gen LikudSupportVars=0
	replace LikudSupportVars=1 if v109B!=.

	foreach var in v109B v111B v113B v115B v117B v121B v109C v111C v113C v115C v117C v121C {
		quietly summarize `var' if year==0
		local `var'_mean= r(mean)
		local `var'_sd= r(sd) 
		gen c_`var' = (`var'-``var'_mean')/``var'_sd'
		
		egen median_std_`var'1=median(c_`var') if year==1
		replace c_`var' = median_std_`var'1 if year==1 & c_`var'==.
		qui egen median_std_`var'0=median(c_`var') if year==0
		replace c_`var' = median_std_`var'0 if year==0 & c_`var'==.
		
		egen median_`var'1=median(`var') if year==1
		replace `var' = median_`var'1 if year==1 & `var'==.
		qui egen median_`var'0=median(`var') if year==0
		replace `var' = median_`var'0 if year==0 & `var'==.
		drop median_`var'0 median_`var'1 median_std_`var'0 median_std_`var'1
		
		replace c_`var'=. if LikudSupportVars==0
		replace `var'=. if LikudSupportVars==0
		}

	* Creating indices for Likud support
	
	alpha c_v109B c_v111B c_v113B c_v115B c_v117B c_v121B, std gen(LikudSupport)
	make_index_gr LikudSupport wgt v109B v111B v113B v115B v117B v121B
	corr LikudSupport index_LikudSupport
	lab var LikudSupport "Likud Support index"
	lab var index_LikudSupport "Likud Support index"

	local LikudSupport index_LikudSupport LikudSupport v109B v111B v113B v115B v117B v121B
	tabstat `LikudSupport', by (year) stats(mean N)

	* Creating indices for Kadima support
	
	alpha c_v109C c_v111C c_v113C c_v115C c_v117C c_v121C, std gen(KadimaSupport)
	make_index_gr KadimaSupport wgt v109C v111C v113C v115C v117C v121C
	corr KadimaSupport index_KadimaSupport
	lab var KadimaSupport "Kadima Support index"
	lab var index_KadimaSupport "Kadima Support index"

	local KadimaSupport index_KadimaSupport KadimaSupport v109C v111C v113C v115C v117C v121C
	tabstat `KadimaSupport', by (year) stats(mean N)

	*****************************************************
	* Topic: Attitudes peace / war / palestinian domain *
	*****************************************************

	recode v19 (1/3=0)(4=1), gen(v19B)
	recode v17 v18 v36 v37 (1/2=0)(3/4=1) (5=0), gen(v17B v18B v36B v37B)
	recode v20 (1/2=0)(2=1)(4=0), gen(v20B)
	recode v35 (1/2=0)(3=1), gen(v35B)
	recode v39 (2/3=0), gen(v39B)
	recode v46 v21 v60 (4=1)(3=2)(2=3)(1=4), gen(v46B v21B v60B)
	recode v135 (7=1)(6=2)(5=3)(4=4)(3=5)(2=6)(1=7), gen(v135B)

	lab var v17B "Peace with Palestinians isn't possible"
	lab var v18B "Palestinians' ultimate goal to destroy Israel"
	lab var v19B "Peace agreement won't solve conflict"
	lab var v21B "Concerned about Arab violence"
	lab var v35B "Security above rule of law"
	lab var v36 "Oppose Two-States solution"
	lab var v36B "Oppose Two-States solution"
	lab var v39B "Evacuate settlements as part of peace agreement"
	lab var v46B "Disagree to return territories"
	lab var v135B "Self-placement on right-left scale"

	su v17B v18B v19B v21B v26 v27 v31 v35B v36 v39B v45 v46B v47 v90 v135B
	
	* Creating the indices on the topic
	
	alpha v17B v18B v21B v36 v45 v46B v90, st item

	foreach var in v17B v18B v21B v36 v45 v46B v90 {
		quietly summarize `var' if year==0
		local `var'_mean= r(mean)
		local `var'_sd= r(sd) 
		gen c_`var' = (`var'-``var'_mean')/``var'_sd'
		
		egen median_std_`var'1=median(c_`var') if year==1
		replace c_`var' = median_std_`var'1 if year==1 & c_`var'==.
		qui egen median_std_`var'0=median(c_`var') if year==0
		replace c_`var' = median_std_`var'0 if year==0 & c_`var'==.
		
		egen median_`var'1=median(`var') if year==1
		replace `var' = median_`var'1 if year==1 & `var'==.
		qui egen median_`var'0=median(`var') if year==0
		replace `var' = median_`var'0 if year==0 & `var'==.
		drop median_`var'0 median_`var'1 median_std_`var'0 median_std_`var'1
		}

	alpha c_v17B c_v18B c_v21B c_v36 c_v45 c_v46B c_v90, st gen(medini)
	make_index_gr medini wgt v17B v18B v21B v36 v45 v46B c_v90
	corr medini index_medini
	lab var medini "Right attitudes index"
	lab var index_medini "Right attitudes index"

	local medini medini index_medini v17B v18B v21B v36 v45 v46B v90
	tabstat `medini', by (year)

	************************************
	* Topic: Attitudes economic domain *
	************************************
	
	recode v41 (1/2=0) (6=0)(3/5=1), gen(v41B)
	lab var v41B "Socialism over Capitalism"

	gen v34B=v34==1
	lab var v34B "Gov Intervention in markets"
	corr v34B v41B

	local economy v34B v41B
		
	*************************************
	* Preparing the regressions section *
	*************************************
	
	estimates drop _all

	* Running the diff and diff situation to ousheet results for Table 5, SI-18 and SI-19
	
	foreach y in `partyF' `partyS' `Netanyahu' `LikudSupport' `KadimaSupport' `medini' `economy'{
		
		reg `y' c.IHsd##year $controls [aw=obssemel], cl(area_num)
		estimate store `y'_m1
		
		}

	* Outsheeting results for Table 5 (Evaluation of Parties)
	
	# delimit ;	
		esttab LikudF_m1 KadimaF_m1 LaborF_m1 ShasF_m1 HabayitHayehudiF_m1 IsraelBeiteinuF_m1
		using "Tables/Table_5.tex", replace
			 keep (IHsd 1.year 1.year#c.IHsd  _cons)
			 order(IHsd 1.year 1.year#c.IHsd _cons)
				cells(b(fmt(%5.3f) star) se(fmt(%5.3f) par))
				starlevels(* .10 ** .05 *** .01) 					
				mgroups("\textbf{Likud}" "\textbf{Kadima}" "\textbf{Labor}" "\textbf{Shas}" "\textbf{BY}" "\textbf{IB}", pattern(1 1 1 1 1 1)
				span prefix(\multicolumn{@span}{c}{) suffix(}) erepeat(\cmidrule(lr){@span})) nomtitles
				varlabels(IHsd "IH exposure" 1.year "Post" 1.year#c.IHsd "IH $\times$ Post"  _cons "Constant")
				stats(r2 N, labels("R2" "N" )
				fmt(2 0)) collabels(none) label booktabs nonotes;
		#delimit cr		
	
	* Outsheeting results for Table SI-18 (Support for Netanyahu)

	# delimit ;	
		esttab index_Netanyahu_m1 v71_m1 v123B_m1 v125B_m1 v127B_m1 v129B_m1 
		using "Tables/Table_SI-18.tex", replace
				keep (IHsd 1.year 1.year#c.IHsd  _cons)
				order(IHsd 1.year 1.year#c.IHsd _cons)
				cells(b(fmt(%5.3f) star) se(fmt(%5.3f) par))
				starlevels(* .10 ** .05 *** .01) 					
				mgroups("\textbf{Index}" "\textbf{Support 1-10}" "\textbf{Leader}" "\textbf{Trustworthy}" "\textbf{Patriotic}" "\textbf{Deal maker}", pattern(1 1 1 1 1 1)
				span prefix(\multicolumn{@span}{c}{) suffix(}) erepeat(\cmidrule(lr){@span})) nomtitles
				varlabels(IHsd "IH exposure" 1.year "Post" 1.year#c.IHsd "IH $\times$ Post"  _cons "Constant")
				stats(r2 N, labels("R2" "N" )
				fmt(2 0)) collabels(none) label booktabs nonotes;
		#delimit cr		
	
	* Outsheeting results for Table SI-18 (Support for Attitudes peace / war / palestinian domain)

	# delimit ;	
		esttab index_medini_m1 v17B_m1 v18B_m1 v21B_m1 v36_m1 v45_m1 v46B_m1 v90_m1 v34B_m1 v41B_m1 
		using "Tables/Table_SI-19.tex", replace
				keep (IHsd 1.year 1.year#c.IHsd  _cons)
				order(IHsd 1.year 1.year#c.IHsd _cons)
				cells(b(fmt(%5.3f) star) se(fmt(%5.3f) par))
				starlevels(* .10 ** .05 *** .01) 					
				mgroups("\textbf{Index}" "\textbf{Peace}" "\textbf{Goals}" 
				"\textbf{Violence}" "\textbf{Two-States}" "\textbf{Talks}"
				"\textbf{Settlements}" "\textbf{Right scale}" "\textbf{Gov Intervention}" "\textbf{Socialism}", pattern(1 1 1 1 1 1 1 1 1 1)
				span prefix(\multicolumn{@span}{c}{) suffix(}) erepeat(\cmidrule(lr){@span})) nomtitles
				varlabels(IHsd "IH exposure" 1.year "Post" 1.year#c.IHsd "IH $\times$ Post"  _cons "Constant")
				stats(r2 N, labels("R2" "N" )
				fmt(2 0)) collabels(none)	label booktabs nonotes;
		#delimit cr		
		



